//
//  RMMAddNewAdressView.m
//  Romomo
//
//  Created by puman on 16/10/12.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMAddNewAdressView.h"

@implementation RMMAddNewAdressView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = RGBA(245, 246, 247, 1);
        NSArray *nameArr = @[@"姓名",@"联系电话",@"服务地址",@"小区名称",@"门牌号"];
        NSArray *plArray = @[@"您的姓名",@"手机号码",@"市/区",@"所在小区或街道",@"门牌号/详细地址"];

        for (int i = 0; i < 5; i++) {
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, kHalf * i, kScreenWideth, kHalf)];
            view.backgroundColor = kWhiteColor;
            [self addSubview:view];
            
            UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 70, 49)];
            titleLabel.text = nameArr[i];
            titleLabel.font = kFont(16);
            titleLabel.textColor = COLORFROMCODE(0x2C2C2C, 1);
            [view addSubview:titleLabel];
            
            UITextField *contentF = [[UITextField alloc] initWithFrame:CGRectMake(90, 0, kScreenWideth - 120, 49)];
            contentF.tag = 10 + i;
            contentF.placeholder = plArray[i];
            contentF.font = kFont(14);
            [view addSubview:contentF];
            
            UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWideth - 30, 17, 16, 16)];
            imageV.image = [UIImage imageNamed:@"more-2@3x"];
            imageV.hidden = YES;
            [view addSubview:imageV];

            if (i == 2) {
                imageV.hidden = NO;
                contentF.userInteractionEnabled = NO;
                _showBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
                _showBut.frame = view.bounds;
                [view addSubview:_showBut];
            } else if (i == 1) {
                contentF.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
            } else if (i == 3) {
                imageV.hidden = NO;
                _adressBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
                _adressBut.frame = view.bounds;
                [view addSubview:_adressBut];
            }
            
            UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 49.5, view.width - 15, 0.5)];
            lineLabel.backgroundColor = RGBA(221, 221, 221, 1);
            [view addSubview:lineLabel];
        }
        
        UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 266, kScreenWideth, 54)];
        bottomView.backgroundColor = kWhiteColor;
        [self addSubview:bottomView];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 200, bottomView.height)];
        label.text = @"设为默认";
        label.font = kFont(16);
        label.textColor = COLORFROMCODE(0x2C2C2C, 1);
        [bottomView addSubview:label];
        
        _mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(kScreenWideth - 65, 9.5, 50, 35)];
        _mySwitch.onTintColor = COLORFROMCODE(0x53C7C6, 1);
        [bottomView addSubview:_mySwitch];

        _upDataBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _upDataBut.frame = CGRectMake(kHalf, bottomView.bottom + 24, kScreenWideth - kHalf * 2, 40);
        _upDataBut.backgroundColor = RGBA(238, 238, 238, 1);
        _upDataBut.layer.cornerRadius = kMaric;
        [_upDataBut setTitleColor:COLORFROMCODE(0xD7D7D7, 1) forState:(UIControlStateNormal)];
        _upDataBut.userInteractionEnabled = NO;
        _upDataBut.layer.borderColor = COLORFROMCODE(0xEEEEEE, 1).CGColor;
        _upDataBut.layer.borderWidth = 1;
        [_upDataBut setTitle:@"确定新增" forState:(UIControlStateNormal)];
        _upDataBut.titleLabel.font = kFont(14);
        [self addSubview:_upDataBut];

    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
